/**
 * Created by thinkpad on 14-6-26.
 */
//险种表
"use strict";
var mongoose = require('../index');
var mongoosePaginate = require('mongoose-paginate');
var updatedTimestamp = require('mongoose-updated_at');
var ObjectId = mongoose.Schema.Types.ObjectId;

var saleProductSchema = new mongoose.Schema({
    providerId: { type: ObjectId, ref: "Provider" }, //保险公司ID
    providerName: { type: String }, //供应商名称
    icpCode: { type: String }, //保司代码
    productAbbr: String, //商品简称
    planRiderType: String, //主附标志 1-主险 2-附加险
    planAttrType: { type: String }, //保监分类
    basicLawType: { type: String }, //基本法分类
    statisticsType: { type: String }, //统计分类
    productName: { type: String }, //商品名称
    productCode: { type: String }, //商品代码
    sagencyfee: { type: String }, //代理费开始
    eagencyfee: { type: String }, //代理费结束
    //商品类型  1寿险 2车险 3意健险 4理财险 5企财险 6保险 7家财险 8健康险 详细查看lib/baseCode/product.js
    productType: { type: String },
    //出单方式 1-正常 2-链接 3-清单
    issueType: String,
    //保费账户 account1,account2,account3
    accountName: String,
    realSalesVolume: { type: Number, default: 0 },
    channelType: [String], //渠道信息
    branchCode: [String], //销售机构信息
    branch: String, //操作记录人机构信息
    saleWays: [String], //销售方式
    saleStartDate: Date, //销售开始日期
    saleEndDate: Date, //销售截止日期
    publishDate: { type: String },
    //产品状态 0-待发布 1-已开售 2-停售 8-已删除
    productStatus: { type: String, default: '0' },
    productCustomer: [String], //销售对象
    typetags: [String], //产品分类标签
    suitableGroup: [String], //产品自定义标签
    ensureScope: [String], //保障范围
    productcity: [String], //销售地区
    correctTerm: [String], //支持的批改项
    hesitatePeriod: String, //犹豫期
    visitDay: String,//回访天数
    //签约方
    parties: [
        {
            partiesId: {
                type: ObjectId,
                ref: 'parties'
            },
            partiesName: String
        }
    ],
    feeType: [String],  //费用类型
    safePeriod: [String],//保险期间
    paymentMethod: [String],//缴费方式

    claimDatum: String,//理赔资料
    claimRemark: String,//理赔描述

    orderNo: { type: Number, default: 10000 }, //排列顺序

    //外部系统产品ID
    externalProductId: String,
    //外部系统产品名称
    externalProducttName: String,

    test: {
        a: String,
        b: String,
    },

    createdAt: {
        type: Date,
        default: Date.now
    }
}, { collection: 'saleproducts' });

saleProductSchema.plugin(updatedTimestamp);
saleProductSchema.plugin(mongoosePaginate);

module.exports = mongoose.model('SaleProduct', saleProductSchema);
